package logic

import (
	"context"
	"shop/models/mysql"

	"shop/shoprpc/internal/svc"
	"shop/shoprpc/shoprpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShopAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewShopAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShopAddLogic {
	return &ShopAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ShopAddLogic) ShopAdd(in *shoprpc.ShopAddRequest) (*shoprpc.ShopAddResponse, error) {
	// todo: add your logic here and delete this line
	var shop mysql.Shop
	
	shop = mysql.Shop{
		Name:   in.Name,
		Price:  float64(in.Price),
		Number: int(in.Number),
	}
	mysql.DB.Debug().Create(&shop)
	return &shoprpc.ShopAddResponse{
		ShopId: int64(shop.ID),
	}, nil
}
